package com.example.springboot_test.easyexcel.model;

import com.example.springboot_test.easyexcel.model.builder.RowHeightColWidthModelBuilder;
import com.example.springboot_test.easyexcel.model.common.SheetModel;
import lombok.Getter;

/**
 * 行高列宽信息（Builder构建者模式）
 *
 * @author xudongmaster
 */
@Getter
public class RowHeightColWidthModel extends SheetModel {

    /**
     * 行号
     */
    private final Integer rowIndex;
    /**
     * 列号
     */
    private final Integer colIndex;
    /**
     * 行高
     */
    private final Float rowHeight;
    /**
     * 列宽
     */
    private final Integer colWidth;

    public RowHeightColWidthModel(RowHeightColWidthModelBuilder builder) {
        this.sheetName = builder.getSheetName();
        this.rowIndex = builder.getRowIndex();
        this.colIndex = builder.getColIndex();
        this.rowHeight = builder.getRowHeight();
        this.colWidth = builder.getColWidth();
    }


    /**
     * 创建隐藏行信息
     *
     * @param sheetName sheet页名称
     * @param rowIndex  行号
     * @return 隐藏行信息
     */
    public static RowHeightColWidthModel createHideRowModel(String sheetName, Integer rowIndex) {
        return createRowHeightColWidthModel(sheetName, rowIndex, 0f, null, null);
    }

    /**
     * 创建隐藏列信息
     *
     * @param sheetName sheet页名称
     * @param colIndex  列号
     * @return 隐藏行信息
     */
    public static RowHeightColWidthModel createHideColModel(String sheetName, Integer colIndex) {
        return createRowHeightColWidthModel(sheetName, null, null, colIndex, 0);
    }

    /**
     * 创建行高信息
     *
     * @param sheetName sheet页名称
     * @param rowIndex  行号
     * @param rowHeight 行高
     * @return 隐藏行信息
     */
    public static RowHeightColWidthModel createRowHeightModel(String sheetName, Integer rowIndex, Float rowHeight) {
        return createRowHeightColWidthModel(sheetName, rowIndex, rowHeight, null, null);
    }

    /**
     * 创建列宽信息
     *
     * @param sheetName sheet页名称
     * @param colIndex  列号
     * @param colWidth  列宽
     * @return 隐藏行信息
     */
    public static RowHeightColWidthModel createColWidthModel(String sheetName, Integer colIndex, Integer colWidth) {
        return createRowHeightColWidthModel(sheetName, null, null, colIndex, colWidth);
    }

    /**
     * 创建行高列宽信息
     *
     * @param sheetName sheet页名称
     * @param rowIndex  行号
     * @param rowHeight 行高
     * @param colIndex  列号
     * @param colWidth  列宽
     * @return 隐藏行信息
     */
    public static RowHeightColWidthModel createRowHeightColWidthModel(String sheetName, Integer rowIndex, Float rowHeight, Integer colIndex, Integer colWidth) {
        return RowHeightColWidthModelBuilder.builder(sheetName)
                //行号
                .rowIndex(rowIndex)
                //行高
                .rowHeight(rowHeight)
                //显示列号
                .colIndex(colIndex)
                //列宽
                .colWidth(colWidth)
                .build();
    }
}
